From: Ximin Luo Date: Mon, 5 Feb 2018 16:04:11 +0000 (+0100) Subject: Make the default behaviour of `cargo build` match the documentation X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~2^2~56^2~6 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=3fc0715d33ccea567526242d2247576930db4a7c;p=cargo.git Make the default behaviour of `cargo build` match the documentation cargo build --help says: --all-targets Build all targets (lib and bin targets by default) but the old default behaviour was actually doing --all-targets. This meant that --avoid-dev-deps was only effectively if one gave --lib --bins explicitly. With this commit, `cargo build --avoid-dev-deps` with no other flags, will build lib and bins and avoid installing dev-dependencies. --- diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index bf905c3af..d7c08c9c4 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -421,7 +421,7 @@ impl<'a> CompileFilter<'a> { pub fn need_dev_deps(&self) -> bool { match *self { - CompileFilter::Default { .. } => true, + CompileFilter::Default { .. } => false, CompileFilter::Only { examples, tests, benches, .. } => examples.is_specific() || tests.is_specific() || benches.is_specific() } @@ -429,7 +429,11 @@ impl<'a> CompileFilter<'a> { pub fn matches(&self, target: &Target) -> bool { match *self { - CompileFilter::Default { .. } => true, + CompileFilter::Default { .. } => match *target.kind() { + TargetKind::Bin => true, + TargetKind::Lib(..) => true, + _ => false, + }, CompileFilter::Only { lib, bins, examples, tests, benches, .. } => { let rule = match *target.kind() { TargetKind::Bin => bins,